package com.freshmarket.freshmarket.service.impl;

import com.freshmarket.freshmarket.controller.form.OrdersPageForm;
import com.freshmarket.freshmarket.entity.Orders;
import com.freshmarket.freshmarket.dao.OrdersMapper;
import com.freshmarket.freshmarket.entity.Pages;
import com.freshmarket.freshmarket.entity.User;
import com.freshmarket.freshmarket.service.IOrdersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Squirrel
 * @since 2020-09-04
 */
@Service
public class OrdersServiceImpl implements IOrdersService {

    @Resource
    private OrdersMapper ordersMapper;
    @Override
    public Pages selectNowPageAll(int pageIndex, int pageSize, String userName, String userPhone, String ordersStatus) throws Exception{
        //条件分页
        List<OrdersPageForm> ordersPageForms = ordersMapper.selectNowPageAll((pageIndex - 1) * pageSize, pageSize, userName, userPhone, ordersStatus);

        //总条数
        int countPage = ordersMapper.selectCountPage(userName, userPhone, ordersStatus);

        Pages success = Pages.success(countPage, pageIndex, pageSize, ordersPageForms);
        return success;

    }
}
